<template>
	<div>
		<section style="height: 3rem;"></section>
		
		<section style="width: 100%;justify-content: center;align-items: center;display: flex;">
			<section style="width: 60%;display: flex;flex-direction: column;">
				
				<mu-select label="请选择" v-model="factoryId" full-width>
						<mu-option v-for="item,index in options" :key="item.id" :label="item.factoryname" :value="item.id"></mu-option>
				</mu-select>
				
				
	  		 <mu-text-field style="margin-top: 2rem;" v-model="userName" placeholder="请输入用户名"></mu-text-field>
			 <mu-text-field style="margin-top: 2rem;" v-model="passwordold" placeholder="请输入旧密码"  type="text"></mu-text-field>
			
			 <mu-text-field style="margin-top: 2rem;" v-model="passwordnew" placeholder="请输入新密码"  type="text"></mu-text-field>

			  	
			  	<section style="margin-top: 2rem;display: flex;justify-content: center;justify-content:space-between;align-items: center;flex-direction: row;" >
			  		
					<mu-button  @click="gotoAddress('factoryList')">返回</mu-button>
					<mu-button color="primary"  @click="ChangePassword()">确定</mu-button>
					
				</section>
			  	 
			</section>
			
			
		</section>
	</div>
</template>
     



<script>
     export default{
     	data(){
     		return {
     			options:[],
     			factoryId:'',
     			userName:'',
     			passwordold:'',
     			passwordnew:'',
     			psd:'',
     			ifDisplay:false
     		}
     	},
     	mounted(){
     		this.getBindlist()
     	},
     	methods:{
     		gotoAddress(path){
     			var self = this
     			setTimeout(function(){
     				self.$router.push(path)
     			},200)
     		},
     		getBindlist(){
    		let that=this
    		that.axios.get(that.global.homeSrc+'/factory/getFactoryListX').then(function(response){
		 		that.options=response.data.data
//		 		that.gotoAddress({path:'index2'})
		 	}).catch(function(error){
		 		console.info(error)
		 	})
		},
     	    ChangePassword(){
     	    	let that = this
     	    	that.axios.post(that.global.homeSrc+'/factoryUser/ChangeFactoryUserPassword',{
     	    		'factoryUsername':that.userName,
				     'passwordold':that.passwordold,
				     'passwordnew':that.passwordnew,
				     'factoryId':that.factoryId
     	    }).then(function(response){//？？？？？？？？
		 		if(response.data.code==0){
		 			if(response.data.data.state=="ok")
		 			{
					console.info(response.data)
					that.$toast.success('修改成功!');
					that.$router.replace("factoryList")
                    }else{
		 		     	//that.$router.go(-1)
						that.$toast.error('修改失败,原因:'+response.data.data.msg);
		 		     }
				}else{
						that.$toast.error('修改失败,原因:'+response.data.data.msg);
				}
		 	}).catch(function(error){
		 		console.info(error)
				that.$toast.error('修改失败,原因:'+response.data.data.msg);
		 		that.$router.replace("factoryList")
		 	})
		},
		clearPassword:function(){
			this.psd='';
		}
     	}
     }
</script>

<style>
	.aboutpass{
      margin-top: 2rem;;
     }
      .aboutpass .psd{
      width:99.9%; 
      }
</style>